<?php
// 本文档自动生成，仅供测试运行
class IndexAction extends Action
{
    /**
    +----------------------------------------------------------
    * 默认操作
    +----------------------------------------------------------
    */
    
    public function __construct(){
    	Action::__construct();
    	$hot= D('Hotkey');
    	$this->toptag25 = $hot->hotTop25();
    	$this->nexttag25 = $hot->hotNext25();
    	
    	$this->assign('toptag',$this->toptag25);
    	$this->assign('nexttag',$this->nexttag25);
    }
    
    public function IndexAction(){
    	$this->__construct();
    }
    
    public function Index()
    {
    	import("ORG.Util.Page");	//导入分页类
    	$Posts = new PostsModel();
		$kid = intval($_GET['kid']) > 0 ?intval($_GET['kid']):'';
		$key = !empty($_GET['key']) ? trim($_GET['key']) :'';
		if($key){
			$this->assign('title',$key);
		}
		if($kid >0 ){
			$List = $Posts->relation(true)->where("see = 1 AND `kid` = '$kid' ")->order('pid DESC')->page($_GET['p'].',20')->select();
			$Count = $Posts->where("see = 1 AND `kid` = '$kid' ")->count();
		}else{
			$List = $Posts->relation(true)->where('see = 1')->order('pid DESC')->page($_GET['p'].',20')->select();
			$Count = $Posts->where("see = 1")->count();
		}
    	foreach ($List as $k=>$v) {
    		$List[$k]['content'] = gzdecode($v['content']);
    	}
    	$this->assign('list',$List);
    	$this->assign('count',$Count);
    	$Page = new Page($Count,20); // 实例化分页类传入总记录数和每页显示的记录数
    	$Page->setConfig('theme','%upPage% %first%  %prePage%  %linkPage%  %nextPage% %downPage% %end%');
		$show = $Page->show('Index/index'); // 分页显示输出
		$show = str_replace('index.php/Index/index/','',$show);
		$this->assign('page',$show); // 赋值分页输出
		
        $this->display();
        $this->assign();
    }
    
}